#ifndef CSPRITE_MANAGER_H
#define CSPRITE_MANAGER_H

#include <vector>
#include <string>
#include <SDL.h>
#include "CBlockView.h"

enum ESpriteType {
	BROWN_BLOCK,
	CHARACTER_BOY,
	CHARACTER_CAT_GIRL,
	CHARACTER_HORN_GIRL,
	CHARACTER_PINK_GIRL,
	CHARACTER_PRINCESS_GIRL,
	CHEST_CLOSED,
	CHEST_LID,
	CHEST_OPEN,
	DIRT_BLOCK,
	DOOR_TALL_CLOSED,
	DOOR_TALL_OPEN,
	ENEMY_BUG,
	GEM_BLUE,
	GEM_GREEN,
	GEM_ORANGE,
	GRASS_BLOCK,
	HEART,
	KEY,
	PLAIN_BLOCK,
	RAMP_EAST,
	RAMP_NORTH,
	RAMP_SOUTH,
	RAMP_WEST,
	ROCK,
	ROOF_EAST,
	ROOF_NORTH,
	ROOF_NORTH_EAST,
	ROOF_NORTH_WEST,
	ROOF_SOUTH,
	ROOF_SOUTH_EAST,
	ROOF_SOUTH_WEST,
	ROOF_WEST,
	SELECTOR,
	SHADOW_EAST,
	SHADOW_NORTH,
	SHADOW_NORTH_EAST,
	SHADOW_NORTH_WEST,
	SHADOW_SIDE_WEST,
	SHADOW_SOUTH,
	SHADOW_SOUTH_EAST,
	SHADOW_SOUTH_WEST,
	SHADOW_WEST,
	SPEECH_BUBBLE,
	STAR,
	STONE_BLOCK,
	STONE_BLOCK_TALL,
	TREE_SHORT,
	TREE_TALL,
	TREE_UGLY,
	WALL_BLOCK,
	WALL_BLOCK_TALL,
	WATER_BLOCK,
	WINDOW_TALL,
	WOOD_BLOCK,
	SIZE_SPRITE_TYPE,
};

typedef enum ESpriteType SpriteType;

const ESpriteType BlockSprites[] = 
{
	BROWN_BLOCK,
	DIRT_BLOCK,
	GRASS_BLOCK,
	PLAIN_BLOCK,
	STONE_BLOCK,
	WALL_BLOCK,
	WOOD_BLOCK,
	WATER_BLOCK,
};

class CSprite;
struct SDL_Surface;

class CSpriteManager
{
public:
	CSpriteManager(const std::string& content_path = "Content", const std::string& extension = "png");
	~CSpriteManager();
	const CSprite* Get(SpriteType t) const;
	void LoadSprites();

	struct BlockSprite
	{
		int x, y;
		SDL_Rect r;
	};

	void DrawBlock(const CBlockView& v, SDL_Surface* surf, int x, int y);
private:
	
	void BuildBlocksSprites();
	typedef std::vector<CSprite*> scontainer;
	scontainer Sprites;
	std::string ContentPath;
	std::string Extension;

	int surf_w;
	int surf_h;
	int surf_x;
	int surf_y;
	SDL_Surface* CreateNewSurface();

	BlockSprite block_rects[B_SIZE_BLOCK * (2*shadows_left_size + shadows_side_size)];
	SDL_Surface* SurfaceBlocks;
};

#endif // CSPRITE_MANAGER_H

